var LODOP; // 声明为全局变量
function CreatePrintPage() {
	LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
//	LODOP.SET_PRINT_STYLE("FontSize",10); 
	LODOP.ADD_PRINT_TEXT(100, 115, 75, 24, $('#senderName').val());// 寄件人姓名
	LODOP.ADD_PRINT_TEXT(100, 270, 100, 24, $('#departure').val());// 始发地
	LODOP.ADD_PRINT_TEXT(135, 115, 250, 24, $('#senderCompanyName').val());// 寄件人单位名称
	LODOP.ADD_PRINT_TEXT(165, 105, 65, 24, $('#senderProvince').val());// 寄件人省
	LODOP.ADD_PRINT_TEXT(165, 190, 65, 24, $('#senderCity').val());// 寄件人市
	LODOP.ADD_PRINT_TEXT(165, 280, 65, 24, $('#senderCountry').val());// 寄件人县
	LODOP.ADD_PRINT_TEXT(199, 85, 300, 24, $('#senderAddress').val());// 寄件人地址
	LODOP.ADD_PRINT_TEXT(230, 140, 90, 24, $('#senderPhone').val());// 寄件人电话
	LODOP.ADD_PRINT_TEXT(230, 240, 90, 24, $('#senderMobile').val());// 寄件人手机号
	// LODOP.ADD_PRINT_HTM(225,335,30,20,"<input type='checkbox' checked/>");
	LODOP.ADD_PRINT_TEXT(255, 113, 250, 24, "");// 内件名
	// LODOP.ADD_PRINT_HTM(278,100,22,20,"<input type='checkbox' checked/>");
	LODOP.ADD_PRINT_TEXT(279, 306, 24, 24, "");// 金额万
	LODOP.ADD_PRINT_TEXT(279, 338, 24, 24, "");// 金额千
	LODOP.ADD_PRINT_TEXT(279, 372, 24, 24, "");// 金额百
	LODOP.ADD_PRINT_TEXT(279, 406, 24, 24, "");// 金额十
	LODOP.ADD_PRINT_TEXT(279, 447, 24, 24, "");// 金额元
	// LODOP.ADD_PRINT_HTM(302,97,22,20,"<input type='checkbox' checked/>");
	// LODOP.ADD_PRINT_HTM(302,279,22,20,"<input type='checkbox' checked/>");
	// LODOP.ADD_PRINT_HTM(302,375,22,20,"<input type='checkbox' checked/>");
	LODOP.ADD_PRINT_TEXT(352, 99, 189, 24, "");// 寄件人证件号
	LODOP.ADD_PRINT_TEXT(326, 124, 95, 24, "");// 输入框寄件人签名
	LODOP.ADD_PRINT_TEXT(390, 140, 150, 19, getNowFormatDate());//输入框寄件日期
	LODOP.ADD_PRINT_TEXT(100, 470, 75, 24, $('#receiverName').val());// 收件人姓名
	LODOP.ADD_PRINT_TEXT(100, 620, 100, 24, $('#destination').val());// 始发地
	LODOP.ADD_PRINT_TEXT(135, 480, 250, 24, $('#receiverCompanyName').val());// 收件人单位名称
	LODOP.ADD_PRINT_TEXT(165, 450, 65, 24, $('#receiverProvince').val());// 收件省份
	LODOP.ADD_PRINT_TEXT(165, 540, 65, 24, $('#receiverCity').val());// 收件市
	LODOP.ADD_PRINT_TEXT(165, 625, 65, 24, $('#receiverCountry').val());// 收件县
	LODOP.ADD_PRINT_TEXT(200, 400, 300, 24, $('#receiverAddress').val());// 收件人地址
	LODOP.ADD_PRINT_TEXT(230, 500, 90, 24, $('#receiverPhone').val());// 收件人手机号码
	LODOP.ADD_PRINT_TEXT(230, 605, 90, 24, $('#receiverMobile').val());// 收件人电话
	LODOP.ADD_PRINT_SETUP_BKIMG("<img border='0' src='../images/siwu.jpg'>");
	LODOP.SET_SHOW_MODE("BKIMG_LEFT", 1);
	LODOP.SET_SHOW_MODE("BKIMG_TOP", 1);
	LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "315mm");
	LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "120mm");
	LODOP.SET_PRINT_PAGESIZE("1", "2300", "1270", "");
	LODOP.PRINT_DESIGN();
}
function addToSender(senderName, departure, senderCompanyName, senderProvince,
		senderCity, senderCountry, senderAddress, senderPhone, senderMobile) {
	$("#senderName").val(senderName);
	$("#departure").val(departure);
	$("#senderCompanyName").val(senderCompanyName);
	$("#senderProvince").val(senderProvince);
	$("#senderCity").val(senderCity);
	$("#senderCountry").val(senderCountry);
	$("#senderAddress").val(senderAddress);
	$("#senderPhone").val(senderPhone);
	$("#senderMobile").val(senderMobile);
}
function addToReceiver(senderName, departure, senderCompanyName,
		senderProvince, senderCity, senderCountry, senderAddress, senderPhone,
		senderMobile) {
	$("#receiverName").val(senderName);
	$("#destination").val(departure);
	$("#receiverCompanyName").val(senderCompanyName);
	$("#receiverProvince").val(senderProvince);
	$("#receiverCity").val(senderCity);
	$("#receiverCountry").val(senderCountry);
	$("#receiverAddress").val(senderAddress);
	$("#receiverPhone").val(senderPhone);
	$("#receiverMobile").val(senderMobile);
}

function insertSender(type) {
	var sender;
	if (type == 0) {
		sender = {
			"senderName" : $("#senderName").val(),
			"departure" : $("#departure").val(),
			"senderCompanyName" : $("#senderCompanyName").val(),
			"senderProvince" : $("#senderProvince").val(),
			"senderCity" : $("#senderCity").val(),
			"senderCountry" : $("#senderCountry").val(),
			"senderAddress" : $("#senderAddress").val(),
			"senderPhone" : $("#senderPhone").val(),
			"senderMobile" : $("#senderMobile").val()
		};
	} else if (type == 1) {
		sender = {
			"senderName" : $("#receiverName").val(),
			"departure" : $("#destination").val(),
			"senderCompanyName" : $("#receiverCompanyName").val(),
			"senderProvince" : $("#receiverProvince").val(),
			"senderCity" : $("#receiverCity").val(),
			"senderCountry" : $("#receiverCountry").val(),
			"senderAddress" : $("#receiverAddress").val(),
			"senderPhone" : $("#receiverPhone").val(),
			"senderMobile" : $("#receiverMobile").val()
		};
	}
	$.ajax({
		type:"post",
		data:sender,
		url:"../lodop/insert.do",
		dataType:"json",
		success:function(data){
			if(data.code=="200"){
				alert("保存成功");
			}else{
				alert(data.result);
			}
		}
	});
}

function getNowFormatDate() {
    var date = new Date();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + "    " + month + "    " + strDate
            + "   " + date.getHours();
    return currentdate;
}